/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import java.util.regex.Pattern;

/**
 * <p>Project: javase - Ex
 * <p>Powered by webrx On 2021-12-21 15:30:20
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Ex {
    public static void main(String[] args) {
        Random rand = new Random();
        Set<String> set = new HashSet<String>();
        while (true) {
            int a = rand.nextInt(20);
            int b = rand.nextInt(20);
            int c = rand.nextInt(20);
            String o = String.format("%2d %s %2d %s %2d =     ", a, rand.nextBoolean() ? "+" : "-", b, rand.nextBoolean() ? "+" : "-", c);
            var m = Pattern.compile("[+-]\\d").matcher(o.replace(" ", "").replace("=", ""));
            int sum = 0;
            while (m.find()) {
                sum += Integer.parseInt(m.group());
            }
            if (sum >= 0) set.add(o);
            if (set.size() > 4000) break;
        }
        System.out.println(set);
    }
}
